# 连接数据库
from sqlalchemy.ext.asyncio import AsyncSession
# 数据库表结构
from module_admin.entity.vo.employee_salary_vo import EmployeeSalaryQueryModel
# 数据库操作层
from module_admin.dao.employee_salary_dao import EmployeeSalaryDao
# 下划线形式(snake_case)转小驼峰形式(camelCase)工具方法
from utils.common_util import CamelCaseUtil


class EmployeeSalaryService:
    """
    员工薪资模块服务层
    """

    @classmethod
    async def get_employee_salary_list_services(cls, query_db: AsyncSession, page_object: EmployeeSalaryQueryModel, data_scope_sql: str, is_page: bool = False):
        """
        获取员工薪资列表信息service

        :param query_db: orm对象
        :param page_object: 分页查询参数对象
        :param data_scope_sql: 数据权限对应的查询sql语句
        :param is_page: 是否开启分页
        :return: 员工薪资列表信息对象
        """
        salary_list_result = await EmployeeSalaryDao.get_employee_salary_list(query_db, page_object, data_scope_sql, is_page)
        return salary_list_result
    
    @classmethod
    async def get_employee_salary_services(cls, query_db: AsyncSession, salary_id: int):
        """
        获取单个员工薪资详情service
        :param query_db: orm对象
        :param salary_id: 薪资ID
        :return: 员工薪资详情
        """
        result = await EmployeeSalaryDao.get_employee_salary(query_db, salary_id)
        return result

    @classmethod
    async def add_employee_salary_services(cls, query_db: AsyncSession, page_object: EmployeeSalaryQueryModel):
        """
        新增员工薪资信息service
        :param query_db: orm对象
        :param page_object: 新增薪资对象
        :return: 新增结果
        """
        result = await EmployeeSalaryDao.add_employee_salary(query_db, page_object)
        return result

    @classmethod
    async def update_employee_salary_services(cls, query_db: AsyncSession, page_object: EmployeeSalaryQueryModel):
        """
        修改员工薪资信息service
        :param query_db: orm对象
        :param page_object: 修改薪资对象
        :return: 修改结果
        """
        result = await EmployeeSalaryDao.update_employee_salary(query_db, page_object.id, page_object)
        return result

    @classmethod
    async def delete_employee_salary_services(cls, query_db: AsyncSession, salary_id: int):
        """
        删除员工薪资信息service
        :param query_db: orm对象
        :param salary_id: 薪资ID
        :return: 删除结果
        """
        result = await EmployeeSalaryDao.delete_employee_salary(query_db, salary_id)
        return result

    @classmethod
    async def export_employee_salary_services(cls, query_db: AsyncSession, page_object: EmployeeSalaryQueryModel):
        """
        导出员工薪资数据service
        :param query_db: orm对象
        :param page_object: 查询参数对象
        :return: 导出结果
        """
        result = await EmployeeSalaryDao.get_employee_salary_list(query_db, page_object, "", False)
        return result 